/* stylelint-disable */
@import "~scss/variables";
@import "~scss/mixins";

.sw-colorpicker {
    position: relative;

    &__previewWrapper {
        position: relative;
        width: 22px;
        height: 22px;
        border-radius: $border-radius-default;
        overflow: hidden;
        cursor: pointer;
    }

    &__previewColor {
        position: absolute;
        width: 100%;
        height: 100%;
        background: transparent;
    }

    &__previewBackground {
        width: 100%;
        height: 100%;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90' width='100%25' height='100%25'%3E%3Crect width='30' height='30' x='00' y='00' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='30' y='30' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='60' y='00' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='60' y='60' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='00' y='60' fill='%23cdd5db' /%3E%3C/svg%3E");

        &.is--invalid::after {
            position: absolute;
            content: '';
            width: 100%;
            height: 100%;
            background-size: contain;
            background-position: left;
            left: 0;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90' width='100%25' height='100%25'%3E%3Cline x1='0' y1='90' x2='90' y2='0' style='stroke:%23DE294C;stroke-width:10' /%3E%3C/svg%3E");
        }
    }

    &__colorpicker-position {
        position: absolute;
        top: calc(100% + 5px);
        left: 0;
        width: 240px;
    }

    &__row {
        display: flex;
        margin-top: 10px;

        &-column {
            display: flex;
            flex-direction: column;
            width: 35px;
            margin-right: 5px;

            &-label {
                text-align: center;
                color: $color-darkgray-200;
                font-size: $font-size-xs;
                margin-top: 2px;
                user-select: none;
                -moz-user-select: none;
                -webkit-user-select: none;
                -ms-user-select: none;
            }

            &:first-of-type {
                flex: 1;
            }

            &:last-of-type {
                margin-right: 0;
            }
        }
    }

    &__input-row {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    &__sliders {
        flex: 1;
    }

    &__colorpicker {
        width: 260px;
        padding: 10px;
        border: 1px solid $color-gray-300;
        background-color: $color-white;
        border-radius: $border-radius-default;
        box-shadow: 0 3px 6px 0 rgba(120, 138, 155, 0.5);

        &::before {
            content: '';
            position: absolute;
            width: 12px;
            height: 12px;
            top: -6px;
            left: 20px;
            border: 1px solid $color-gray-300;
            border-bottom: none;
            border-right: none;
            background: $color-white;
            transform: rotate(45deg);
        }

        &--compact {
            position: absolute;
            top: 30px;
            left: -20px;
            z-index: 10;

            &::before {
                top: -7px;
            }
        }

        &-selection {
            display: block;
            width: 238px;
            height: 150px;
            border: 1px solid $color-gray-300;
            border-radius: $border-radius-default;
            background-image:
                linear-gradient(180deg, #fff, rgba(255, 255, 255, 0) 50%),
                linear-gradient(0deg, #000, rgba(0, 0, 0, 0) 50%),
                linear-gradient(90deg, #808080, rgba(128, 128, 128, 0) 100%);
        }

        &-selector {
            transform: translate3d(0, 0, 0); // Fixed rendering bug in Safari
            position: relative;
            width: 18px;
            height: 18px;
            border: 3px solid #fff;
            border-radius: 50%;
            box-shadow: 0 0 5px $color-shopware-brand-500;
            cursor: grab;

            &:active {
                cursor: grabbing;
            }
        }

        &-slider-range {
            width: 100%;
            height: 20px;
            border-radius: $border-radius-default;
            background-image: linear-gradient(90deg, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);
            outline: none;
            -webkit-appearance: none;
        }

        &-slider-range::-webkit-slider-thumb {
            height: 26px;
            width: 8px;
            border-radius: $border-radius-default;
            border: 1px solid $color-gray-300;
            background: #fff;
            -webkit-appearance: none;
            cursor: pointer;
        }

        &-slider-range::-moz-range-thumb {
            height: 26px;
            width: 8px;
            border-radius: $border-radius-default;
            border: 1px solid $color-gray-300;
            background: #fff;
            cursor: pointer;
        }

        &-wrapper {
            display: flex;
            height: 58px;
            width: 58px;
            margin-left: 10px;
            justify-content: space-between;

            &.is--small {
                width: 22px;
                height: 22px;

                .sw-colorpicker__colorpicker-previewColor {
                    width: 22px;
                    height: 22px;
                    border: none;
                }

                .sw-colorpicker__colorpicker-previewBackground {
                    width: 22px;
                    height: 22px;
                }
            }
        }

        &-previewColor {
            position: absolute;
            display: inline-block;
            width: 58px;
            height: 58px;
            border: 1px solid $color-gray-300;
            border-radius: $border-radius-default;
        }

        &-previewBackground {
            position: relative;
            display: inline-block;
            width: 58px;
            height: 58px;
            border: 1px solid $color-gray-300;
            border-radius: $border-radius-default;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90' width='100%25' height='100%25'%3E%3Crect width='30' height='30' x='00' y='00' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='30' y='30' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='60' y='00' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='60' y='60' fill='%23cdd5db' /%3E%3Crect width='30' height='30' x='00' y='60' fill='%23cdd5db' /%3E%3C/svg%3E");

            &.is--invalid::after {
                position: absolute;
                content: '';
                width: 100%;
                height: 100%;
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90' width='100%25' height='100%25'%3E%3Cline x1='0' y1='90' x2='90' y2='0' style='stroke:%23DE294C;stroke-width:10' /%3E%3C/svg%3E");
                background-size: contain;
                background-position: left;
            }
        }

        &-input {
            width: 100%;
            min-width: 0;
            height: 32px;
            padding: 0 5px;
            border: 1px solid $color-gray-300;
            border-radius: $border-radius-default;
            font-size: $font-size-xs;
            color: $color-darkgray-200;
            outline: none;

            &[type=number] {
                -moz-appearance: textfield;
            }

            &[type=number]::-webkit-inner-spin-button,
            &[type=number]::-webkit-outer-spin-button {
                -webkit-appearance: none;
            }

            &:last-of-type {
                margin-right: 0;
            }

            &.is--hex {
                flex: 1;
            }

            &:focus {
                border-color: $color-shopware-brand-500;
            }
        }
    }

    &__alpha-slider {
        width: 100%;
        height: 20px;
        margin-top: 10px;
        border: 1px solid $color-gray-300;
        border-radius: $border-radius-default;
        background-image: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='100%25' height='100%25'%3E%3Crect width='10' height='10' x='00' y='00' fill='%23cdd5db' /%3E%3Crect width='10' height='10' x='10' y='10' fill='%23cdd5db' /%3E%3C/svg%3E");
        outline: none;
        -webkit-appearance: none;

        &::-webkit-slider-thumb {
            height: 26px;
            width: 8px;
            border-radius: $border-radius-default;
            border: 1px solid $color-gray-300;
            background: #fff;
            -webkit-appearance: none;
            cursor: pointer;
        }

        &::-moz-range-thumb {
            height: 26px;
            width: 8px;
            border: 1px solid $color-gray-300;
            border-radius: $border-radius-default;
            background: #fff;
            cursor: pointer;
        }
    }

    .is--disabled &__previewWrapper {
        cursor: default;
    }
}

.sw-field__addition {
    position: relative;
    padding: 0;
}

.sw-field__addition.is--prefix {
    display: flex;
    justify-content: center;
    align-items: center;
}

.sw-field__addition .sw-colorpicker__trigger {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.sw-field__addition .sw-colorpicker__trigger .mt-icon {
    line-height: 16px;
}

.sw-popover__wrapper {
    &.--placement-bottom-outside {
        .sw-colorpicker__colorpicker::before {
            top: calc(100% - 7px);
            transform: rotate(225deg);
        }
    }
}
/* stylelint-enable */
